using UnityEngine;

namespace VoxelGame.NPC
{
	[RequireComponent(typeof(CharacterController))]
	public class NPCBehaviour : MonoBehaviour
	{
		[SerializeField]
		protected float _minDuration;

		[SerializeField]
		protected float _maxDuration;

		protected INPC _npcControls;

		private string _stateCurrentAnimation;

		public void Init(INPC npcControls)
		{
			_npcControls = npcControls;
		}

		protected T RandomElement<T>(T[] elements)
		{
			return elements[Random.Range(0, elements.Length)];
		}

		protected void PlayAnimation(string animation)
		{
			_stateCurrentAnimation = animation;
			_npcControls.PlayAnimation(animation);
		}

		public void PlayCurrentAnimation()
		{
			_npcControls.PlayAnimation(_stateCurrentAnimation);
		}
	}
}
